<?php
/*
Copyright 2008, Nathalia


Author:
Nathalia Sautchuk Patrício          (nathalia.sautchuk@gmail.com)

*/
class Cadastrar extends TPage
{

    public function onInit($param)
	{
		parent::onInit($param);
        $this->CPList->DataTextField='Nome';
		$this->CPList->DataValueField='UsuarioID';
        $criteria = new TActiveRecordCriteria;
        $criteria->Condition = "Papel = 2";
		$this->CPList->DataSource=UserRecord::finder()->findAll($criteria);
		$this->CPList->dataBind();

    }    

    public function criarCongresso($sender,$param)
	{
        if($this->IsValid)  // when all validations succeed
        {
            // populates a congressoRecord object with user inputs
            $congressoRecord                       = new CongressoRecord;
            $congressoRecord->DataInicio           = $this->DataInicio->Text; 
            $congressoRecord->DataTermino          = $this->DataTermino->Text; 
            $congressoRecord->DataSubmissaoInicio  = $this->DataSubmissaoInicio->Text; 
            $congressoRecord->DataSubmissaoTermino = $this->DataSubmissaoTermino->Text; 
            $congressoRecord->Nome                 = $this->Nome->Text;
            $congressoRecord->Descricao            = $this->Descricao->Text;
            $congressoRecord->Local                = $this->Local->Text;   
            $congressoRecord->AreaConhecimento     = $this->AreaConhecimento->Text; 
            $congressoRecord->CpID                 = $this->CPList->getSelectedValue();          
 
            // saves to the database via Active Record mechanism
            $congressoRecord->save();
 
            // redirects the browser to the homepage
            $this->Response->redirect('./index.php?page=Congressos.Listar');
        }
    }
}
?>
